package com.klangner.animation.sprites
{
	import com.klangner.animation.path.api.IPath;
	
	import flash.display.GradientType;
	import flash.filters.DropShadowFilter;
	import flash.geom.Matrix;

  public class GradientBox extends MovableSprite {

    private var filter:DropShadowFilter;
    

    public function GradientBox(path:IPath) {
      super(path);
      filter = new DropShadowFilter(0, 0, 0, 1, 20, 20, .3);
      
      paint();
    }
    
    
    public override function move():void{
      super.move();      
      
      filter.distance = -Math.sqrt(x * x + y * y) / 10;
      filter.angle = Math.atan2(y, x) * 180 / Math.PI;
      this.filters = [filter];

    }
  
    private function paint():void {
      graphics.lineStyle(1);
      var colors:Array = [0xffffff, 0xff0000];
      var alphas:Array = [1, 1];
      var ratios:Array = [0, 255];
      var matrix:Matrix = new Matrix();
      matrix.createGradientBox(100, 100, 0, 0, 0);
      graphics.beginGradientFill(GradientType.LINEAR, colors,
                                 alphas, ratios, matrix);
      
      graphics.drawRect(0, 0, 100, 100);
      graphics.endFill();
    }
  }

}